<?php
class Cl_Mailing extends WdkClass 
{
	protected
		/******************************************************/
		//	원본 테이블 정보
		/******************************************************/
		$mailing_seq			= 0		,	//	
		$fk_user_seq			= 0		,	//	
		$mailing_to				= ''	,	//	
		$mailing_title			= ''	,	//	
		$mailing_content		= ''	,	//	
		$mailing_insert_time	= 0		;	//	
		/******************************************************/
		//	추가 정보
		/******************************************************/
	
	/**
	 * 	
	 */
	function __construct()
	{
		parent::__construct();
		self::getDbo();
	}
	
	/**
	 *	
	 */
	public function __init($data)
	{
		parent::__init($data);
		self::dformat();
	}
	
	/**
	 *	
	 */
	public function load($mailing_seq)
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		self::__init($dbo->cLoad($mailing_seq));
	}
	
	/**
	 *	
	 */
	public function dformat()
	{
	
	}
	
	/**
	 * 
	 */
	public function autoUpdate($log='')
	{
		if((int)$this->mailing_seq > 0)
		{
			$this->update($log);
		}
		else
		{
			$this->insert($log);
		}
	}
	
	/**
	 *	
	 */
	public function insert($log='Insert')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$this->mailing_insert_time	= time();
		
		$data = array(	'fk_user_seq'			=>	$this->fk_user_seq,
						'mailing_to'			=>	$this->mailing_to,
						'mailing_title'			=>	$this->mailing_title,
						'mailing_content'		=>	$this->mailing_content,
						'mailing_insert_time'	=>	$this->mailing_insert_time
					);
		$this->mailing_seq = $dbo->insert($data);
		$this->backup($log);
	}
	
	/**
	 * 
	 */
	public function delete($log='delete')
	{
		/*------------------------------------------------------------*/
		$dbo = self::getDbo();
		/*------------------------------------------------------------*/
		$dbo->delete(array("mailing_seq = ".$this->mailing_seq));
		$this->backup($log);
	}
	
	/**
	 *	
	 */
	private function backup($log='')
	{
// 		/*------------------------------------------------------------*/
// 		$dbo = self::getDbo();
// 		/*------------------------------------------------------------*/
// 		$dbo->log($this->user_seq, $log, $this->backup_data);
	}
	
	/**
	 * 
	 */
	public function getDbo()
	{
		return Wdk::model(substr(__CLASS__, 3));
	}
}